<?php

class Adept_Component_Form extends Adept_Component_Control  
{
    
    protected $accept = null;
    protected $acceptCharset = null;
    protected $action = null;
    protected $method = 'post';
    protected $name = null;
    protected $enctype = null;
    protected $target = null;
    
    protected $submitted = false;
    protected $valid = true;
    
    public function processRequest()
    {
        $request = $this->getContext()->getRequest();
        $submitted = $request->get('submitted');
        if (is_array($submitted) && isset($submitted[$this->getId()])) {
            $this->submitted = true;
        } else {
            $this->submitted = false;
        }
    	parent::processRequest();
    }
    
    public function getAccept() 
    {
        return $this->accept;
    }
    
    public function setAccept($accept) 
    {
        $this->accept = $accept;
    }
    
    public function getAcceptCharset() 
    {
        return $this->acceptCharset;
    }
    
    public function setAcceptCharset($acceptCharset) 
    {
        $this->acceptCharset = $acceptCharset;
    }

    public function getAction() 
    {
        if (!is_null($this->action)) {
            return $this->action;
        }
        return $this->getValueOfBinding('action', '');
    }
    
    public function setAction($action) 
    {
        $this->action = $action;
    }
    
    public function getMethod() 
    {
        return $this->method;
    }
    
    public function setMethod($method) 
    {
        $this->method = $method;
    }
    
    public function getName() 
    {
        if ($this->name) {
            return $this->name;
        } else {
            return $this->getId();
        }
    }
    
    public function setName($name) 
    {
        $this->name = $name;
    }
    
    public function getEnctype() 
    {
        return $this->enctype;
    }
    
    public function setEnctype($enctype) 
    {
        $this->enctype = $enctype;
    }
    
    public function getTarget() 
    {
        return $this->target;
    }
    
    public function setTarget($target) 
    {
        $this->target = $target;
    }
    
    public function isSubmitted() 
    {
        return $this->submitted;
    }
    
    public function setSubmitted($submitted) 
    {
        $this->submitted = $submitted;
    }
    
    public function isValid() 
    {
        return $this->valid;
    }
    
    public function setValid($valid) 
    {
        $this->valid = $valid;
    }

    public function hasRenderer() 
    {
        return true;
    }    
    
}